var React = require('react');
var css=require('./bookToTop.css');

var page = React.createClass({
    getInitialState: function() {
        return {
          isShow:false
        };
    },
    pagetotop:function(){
        console.log('totop');
        window.scrollTo(0,0);
    },
    componentDidMount:function(){
        let isShow=false;   
        window.onscroll = function() {
            isShow = (document.body.scrollTop >= 300) ? true : false;
            this.setState({
                isShow:isShow
            })
        }.bind(this);
    },
  	render: function () {
	    return (	
            <a className="am-btn pagetotop" style={this.state.isShow?{display:'block'}:{display:'none'}} onClick={this.pagetotop} >
                <span className="am-icon-angle-double-up am-text-lg"></span>
                <p className="am-margin-0 am-text-xs">置顶</p>
            </a>               
	    );
	  }
});

module.exports = page;


